import { ADD, MINUS, INIT_TEST } from "../constants/counter";

const INITIAL_STATE = {
  num: 0,
  msg: "我是welcome 测试数据",
};

export default function counter(state = INITIAL_STATE, action) {
  switch (action.type) {
    case INIT_TEST:
      console.log("payload:-----");
      return {
        ...state,
        msg: action.payload,
      };
    case ADD:
      return {
        ...state,
        num: state.num + 1,
      };
    case MINUS:
      return {
        ...state,
        num: state.num - 1,
      };
    default:
      return state;
  }
}
